<template>
	<view class="container">
	  <view class="task-info">
			<view class="info-item">
			  <text class="label">学生：</text>
			  <text class="value">{{xsxx.tgsqXsxm}}</text>
			</view>
	    <view class="info-item">
	      <text class="label">所属学院：</text>
	      <text class="value">{{getdeptLabel(xsxx.tgsqSsxy)}}</text>
	    </view>
		<view class="info-item">
		  <text class="label">所属专业：</text>
		  <text class="value">{{xsxx.tgsqSxzy}}</text>
		</view>
	    </view>
	 <view class="task-info">
	    <view class="info-item">
	      <text class="label">原学社导师：</text>
	      <text class="value">{{getTchLabel(xsxx.tgsqYxsds)}}</text>
	    </view>
		<view class="info-item">
		  <text class="label">原学社类别：</text>
		  <text class="value">{{getLabel(xsxx.tgsqXslb)}}</text>
		</view>
		<view class="info-item">
		  <text class="label">原学社：</text>
		  <text class="value">{{getxsxxLabel(xsxx.tgsqYxsmc)}}</text>
		</view>
		<view class="info-item">
		  <text class="label">原岗位名称：</text>
		  <text class="value">{{getgwxxLabel(xsxx.tgsqYgwmc)}}</text>
		</view>
		<view class="info-item">
		  <text class="label">原岗位等级：</text>
		  <text class="value">{{getGwdj(xsxx.tgsqYgwdj)}}</text>
		</view>
		<view class="info-item">
		  <text class="label">原学社审批意见：</text>
		  <text class="value">{{getlabel(xsxx.tgsqYspyj)}}</text>
		</view>
	    <view class="info-item">
	      <text class="label">新学社导师导师：</text>
	      <text class="value">{{getTchLabel(xsxx.tgsqXsds)}}</text>
	    </view>
		<view class="info-item">
		  <text class="label">新学社：</text>
		  <text class="value">{{getxsxxLabel(xsxx.tgsqXxsmc)}}</text>
		</view>
		<view class="info-item">
		  <text class="label">新岗位名称：</text>
		  <text class="value">{{getgwxxLabel(xsxx.tgsqXgwmc)}}</text>
		</view>
		<view class="info-item">
		  <text class="label">新岗位等级：</text>
		  <text class="value">{{getGwdj(xsxx.tgsqXgwdj)}}</text>
		</view>
		<view class="info-item">
		  <text class="label">新学社审批意见：</text>
		  <text class="value">{{getlabel(xsxx.tgsqSpyj)}}</text>
		</view>
		  <view class="header">
		    <text class="title">审批结果：</text>
			 <text class="value">{{getlabel(xsxx.tgsqSpjg)}}</text>
		  </view>
	  </view>
</view>
</template>

<script>
	import { getTgsq } from "@/api/admin/tgsq";
	import { getXsxx ,listXsxx}from "@/api/admin/xsxx";
	import { listTstg }from "@/api/admin/tstg";
	import { getXslb,listXslb }from "@/api/admin/xslb";
	import {listGwxx,getGwxx}from "@/api/admin/gwxx"
	import store from "@/store";
	import {listDeptById}from "@/api/system/dept.js"
	import { allocatedUserList } from "@/api/system/role";
export default {
	data() {
	  return {
		//学社类别
		xslbList:[],
		//岗位信息
		listGwxx:[],
		//学社信息
		xsxxList:[],
	    xsxx: [],
		deptList:[],
		tchList:[],
		  xsid:null,
		  lbid:null,
		  xsmc:null,
		  xslb:null,
		  
	  }
	},
  onLoad(options) {
		  this.getTgsq(options.id)
		  this.getDept(201)
		  this.getTch()
		  this.getlistGwxx();
		  this.getXsxxList();
		  this.getxslb();
        },
		methods:{
			getlabel(value){
				 if(value==='0')
				return '通过'
				else if(value==='1')
				return '已驳回'
				else
				return '待审批'
			},
			getlist(){
				const queryParams={
				        tstgXsxh: store.getters.name,
				        deletemark: null,
				      }
				listTstg(queryParams).then(response=>{
					this.xsid=response.rows[0].tstgXsmc
					this.lbid=response.rows[0].tstgXslb
					this.getlb()
				})
			},
			getTgsq(id){
				getTgsq(id).then(response => {
				  this.xsxx = response.data
				})
			},
			getlb(){
				getXslb(this.lbid).then(response => {
				  this.xslb = response.data.xsglXslb
				})
			},
			//查询部门/学院信息
			getDept(id){
			listDeptById(id).then(response => {
				this.deptList = response.data;
				this.loading = false;
			});
			},
			//获取教师列表
			getTch(){
			const queryParams= {
				roleId: 101
			}
			allocatedUserList(queryParams).then(res => {
				this.tchList = res.rows;
			});
			},/** 查询学社类别 */
    getxslb() {
      this.loading = true;
      listXslb(this.queryParams).then(response => {
        this.xslbList = response.rows;
      });
    },
    //获取学社信息
    getXsxxList(){
      listXsxx().then(response => {
        this.xsxxList = response.rows;
      });
    },
    //获取岗位信息
    getlistGwxx(){
      listGwxx().then(response => {
        this.listGwxx = response.rows;
      });
    }, 
			getdeptLabel(id) {  
				// 创建一个映射函数，该函数将ID映射到标签  
				const map = this.deptList.reduce((acc, item) => {  
					acc[item.deptId] = item.deptName;
					return acc;  
				}, {});  
				// 返回一个函数，该函数接受一个ID并返回相应的标签  
				return map[id] || 'Unknown Label';  
				},
			getTchLabel(userName) {  
				// 创建一个映射函数，该函数将ID映射到标签  
				const map = this.tchList.reduce((acc, item) => {  
				acc[item.userName] = item.nickName;
				return acc;  
				}, {});  
				// 返回一个函数，该函数接受一个ID并返回相应的标签  
				return map[userName] || 'Unknown Label';  
			} ,   
    getLabel(id) {  
      // 创建一个映射函数，该函数将ID映射到标签  
      const map = this.xslbList.reduce((acc, item) => {  
        acc[item.id] = item.xsglXslb;  
        return acc;  
      }, {});  
      // 返回一个函数，该函数接受一个ID并返回相应的标签  
      return map[id] || 'Unknown Label';  
    }  ,
    getgwxxLabel(id) {  
      // 创建一个映射函数，该函数将ID映射到标签  
      const map = this.listGwxx.reduce((acc, item) => {  
        acc[item.id] = item.gwxxGwmc;
        return acc;  
      }, {});  
      // 返回一个函数，该函数接受一个ID并返回相应的标签  
      return map[id] || 'Unknown Label';  
    }   ,
    getxsxxLabel(id) {  
      // 创建一个映射函数，该函数将ID映射到标签  
      const map = this.xsxxList.reduce((acc, item) => {  
        acc[item.id] = item.xsxxXsmc;
        return acc;  
      }, {});  
      // 返回一个函数，该函数接受一个ID并返回相应的标签  
      return map[id] || 'Unknown Label';  
    }  ,
		getGwdj(value){
			if(value==='0')
				return '初'
			else if(value==='1')
				return '中'
				else if(value==='2')
					return '高'
		}
		}
};
</script>


<style scoped>
.container {
  padding: 30rpx;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.header {
  margin: 30rpx 0;
  padding: 20rpx;
}

.title {
  font-size: 36rpx;
  font-weight: 600;
  color: #303133;
  position: relative;
  padding-left: 24rpx;
}

.title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6rpx;
  height: 32rpx;
  background-color: #409eff;
  border-radius: 3rpx;
}

.task-info {
  background-color: #ffffff;
  padding: 30rpx;
  border-radius: 16rpx;
  box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
  margin-bottom: 30rpx;
}

.info-item {
  margin-bottom: 24rpx;
  display: flex;
  align-items: flex-start;
  line-height: 1.6;
}

.label {
  font-size: 28rpx;
  color: #606266;
  width: 200rpx;
  flex-shrink: 0;
}

.value {
  flex: 1;
  font-size: 28rpx;
  color: #303133;
  word-break: break-all;
}

.info-item:last-child {
  margin-bottom: 0;
}

/* 状态标签样式 */
.status-tag {
  display: inline-block;
  padding: 4rpx 16rpx;
  border-radius: 4rpx;
  font-size: 24rpx;
  margin-left: 16rpx;
}

.status-pending {
  background-color: #e6a23c;
  color: #ffffff;
}

.status-approved {
  background-color: #67c23a;
  color: #ffffff;
}

.status-rejected {
  background-color: #f56c6c;
  color: #ffffff;
}

/* 分割线样式 */
.divider {
  height: 1rpx;
  background-color: #ebeef5;
  margin: 24rpx 0;
}

/* 审批信息样式 */
.approval-info {
  margin-top: 24rpx;
  padding-top: 24rpx;
  border-top: 2rpx solid #ebeef5;
}

.approval-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #303133;
  margin-bottom: 16rpx;
}

.approval-content {
  font-size: 28rpx;
  color: #606266;
  line-height: 1.6;
}
</style>